import React, { Component, PropTypes } from 'react'
import List from '../../components/list';
import { Link } from 'react-router'



class OrderList extends Component {
    constructor(props) {
		super(props);
		this.state = {
            remote: {
                method: 'get',
                path: '/v1/exchange/search',
                params: {
                    actId: 1,//暂时写死
                    appCode:"AABBCC",//从app获取过来
                    pageNo: 1,
                    pageSize: 10,
                    status:1
                }
            }
		};
	}
      componentDidMount() {
        this.setState({
             remote: {
                method: 'get',
                path: '/v1/exchange/search',
                params: {
                    actId: 1,//暂时写死
                    appCode:"AABBCC",//从app获取过来
                    pageNo: 1,
                    pageSize: 10,
                    status:1
                }
            }
        })
	}
    	renderItem(rowData, sectionID, rowID) {
		const item = rowData;
		if (!item) {
			return
		}

		return <div className="list" key={rowID}>
			 <section className="list-child">
                    <Link to={`/detail/${item.goodsId}`}>
                        <img src={item.goodsImg} />
                        <section className="detail">
                            <div className="detail-wrapper">
                                <span className="name">{item.goodsName}</span>
                                <span className="desc">{item.goodsDesc}</span>
                                <span className="price">
                                    <span>￥{item.amount}</span>+
                                    <span><i className="icon"></i>{item.integralValue}</span>
                                    <span>￥{item.price}</span>
                                </span>
                            </div>
                        </section>
                    </Link>
                </section>
		</div>
	}
    dataFilter(data){
        var object={
            pageNo:data.pageNo,
            dataList:data.data.dataList[0].goodsList
        }
        return object;

    }
    componentDidMount() {
	}
	render() {
        const {remote} = this.state;
		return (
			<div id="OrderList" className="hasstyle">
                <div className="title">
                    <div>积分兑换</div>
                    <div><Link to={'/myorder'}>订单列表 ></Link></div>
                </div>
                <div className="list">
                    <List
                        remote={remote}
                        renderItem={this.renderItem}
                        renderEmpty={this.renderEmpty}
                        renderLoading={this.renderLoading}
                        renderFail={this.renderFail}
                        dataFilter={this.dataFilter}
                    />
                </div>
			</div>
		)
	}
}

export default OrderList